<?php

$str = "";
if($_GET['member_id']){
    $memIds = str_replace('，', ',', $_GET['member_id']);
    $str .= " and a.member_id in({$memIds})";
}
$sql = "select a.*,b.name as shop_name from ".MICROSHOPCOUPONSPACKAGE." AS a left join ".MICROSHOP." AS b on a.member_id=b.member_id where 1 {$str} order by a.status desc,a.create_time desc";
//=======分页=============
include_once("../includes/page_utf_class.php");
$page = new Page;
$page->listRows=20;
$db->query($sql);
$totalRows = $db->num_rows();
if (!$page->__get('totalRows')){
    $db->query($sql);
    $de['count'] = $page->totalRows = $db->num_rows();
}
$sql .= "  limit ".$page->firstRow.",".$page->listRows;
$de['count']=$de['count']?$de['count']:($_GET['totalRows']?$_GET['totalRows']:'0');
$de['page'] = $page->prompt();
$de['perPageRows'] = $page->listRows;
//=====================
$db->query($sql);
$de['list']=$db->getRows();

$tpl->assign('de',$de);
$tpl->display('coupons_package_list.htm');